//
//  FGYPhoneRegisterView.m
//  01 - shop
//
//  Created by ma c on 16/8/18.
//  Copyright (c) 2016年 beijing. All rights reserved.
//

#import "FGYPhoneRegisterView.h"

@interface FGYPhoneRegisterView ()

@property (strong, nonatomic) UILabel * backGroundLabel;//装输入框的Label;
@property (strong, nonatomic) UILabel * NumFromLabel;
@property (strong, nonatomic) UITextField * testNumField;
@property (strong, nonatomic) UILabel * lineLabel;//分割线Label
@property (strong, nonatomic) UIButton * TestNumBtn;
@property (strong, nonatomic) UIButton * registerBtn;

@end

@implementation FGYPhoneRegisterView

- (UIButton *)registerBtn{
    if (!_registerBtn) {
        _registerBtn = [[UIButton alloc]init];
        _registerBtn.backgroundColor = RGB(234, 234, 234);
        [_registerBtn setTitle:@"注册" forState:UIControlStateNormal];
    }
    return _registerBtn;
}

- (UIButton *)TestNumBtn{
    if (!_TestNumBtn) {
        _TestNumBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_TestNumBtn setTitle:@"30秒后重试" forState:UIControlStateNormal];
        [_TestNumBtn setTitleColor:[UIColor colorWithRed:174 / 255.0 green:174 / 255.0 blue:174 / 255.0 alpha:1] forState:UIControlStateNormal];
    }
    return _TestNumBtn;
}

- (UILabel *)lineLabel{
    if (!_lineLabel) {
        _lineLabel = [[UILabel alloc]init];
        _lineLabel.backgroundColor = RGB(237, 237, 237)
    }
    return _lineLabel;
}

- (UILabel *)backGroundLabel{
    if (!_backGroundLabel) {
        _backGroundLabel = [[UILabel alloc]init];
        _backGroundLabel.backgroundColor = [UIColor whiteColor];
        
    }
    return _backGroundLabel;
}

- (UITextField *)testNumField{
    if (!_testNumField) {
        _testNumField = [[UITextField alloc]init];
        _testNumField.placeholder = @"请输入验证码";
    }
    return _testNumField;
}
- (UILabel *)NumFromLabel{
    if (!_NumFromLabel) {
        _NumFromLabel = [[UILabel alloc]init];
        _NumFromLabel.textColor = RGB(172, 172, 172);
    }
    return _NumFromLabel;
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = RGB(245, 245, 245);
        [self addSubview:self.NumFromLabel];
        [self addSubview:self.backGroundLabel];
        [self addSubview:self.testNumField];
        [self addSubview:self.lineLabel];
        [self addSubview:self.TestNumBtn];
        [self addSubview:self.registerBtn];
    }
    return self;
}

- (void)setUserDict:(NSDictionary *)userDict{
    _userDict = userDict;
    NSString * string = [NSString stringWithFormat:@"验证码已发送到 +86 %@",userDict[@"phoneNume"]];
    NSRange range1 = [string rangeOfString:[NSString stringWithFormat:@"+86 %@",userDict[@"phoneNume"]]];
    NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc]initWithString:string];
    UIColor * color = RGB(0, 189, 240);
    NSDictionary * dict = @{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:color};
    
    [attribute addAttributes:dict range:range1];
    
    self.NumFromLabel.attributedText = attribute;
    
}

- (void)layoutSubviews{
    __weak typeof(self)weakSelf = self;
    [_NumFromLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mas_left).offset(15);
        make.top.equalTo(weakSelf.mas_top);
        make.right.equalTo(weakSelf.mas_right);
        make.height.equalTo(@45);
    }];
    
    [_backGroundLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mas_left);
        make.top.equalTo(weakSelf.NumFromLabel.mas_bottom);
        make.right.equalTo(weakSelf.NumFromLabel.mas_right);
        make.height.equalTo(@50);
        
    }];
    
    [_testNumField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.NumFromLabel.mas_left);
        make.top.equalTo(weakSelf.backGroundLabel.mas_top);
        make.bottom.equalTo(weakSelf.backGroundLabel.mas_bottom);
        make.width.equalTo(@200);
    }];
    
    [_lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.testNumField.mas_right).offset(15);
        make.top.equalTo(weakSelf.backGroundLabel.mas_top).offset(5);
        make.bottom.equalTo(weakSelf.backGroundLabel.mas_bottom).offset(-5);
        make.width.equalTo(@1);
    }];
    
    [_TestNumBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.lineLabel.mas_right).offset(5);
        make.right.equalTo(weakSelf.backGroundLabel.mas_right);
        make.top.equalTo(weakSelf.backGroundLabel.mas_top);
        make.bottom.equalTo(weakSelf.backGroundLabel.mas_bottom);
    }];
    
    [_registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.mas_left).offset(16);
        make.top.equalTo(weakSelf.backGroundLabel.mas_bottom).offset(16);
        make.right.equalTo(weakSelf.mas_right).offset(-16);
        make.height.equalTo(@60);
    }];
    
    
}

@end
